enqueueWork

open fun enqueueWork(@NonNull context: @NonNull Context, @NonNull cls: @NonNull Class<out Any>, jobId: Int, @NonNull work: @NonNull Intent)(source)

Call this to enqueue work for your subclass of JobIntentService. This will either directly start the service (when running on pre-O platforms) or enqueue work for it as a job (when running on O and later). In either case, a wake lock will be held for you to ensure you continue running. The work you enqueue will ultimately appear at onHandleWork.

Parameters

context

Context this is being called from.

cls

The concrete class the work should be dispatched to (this is the class that is published in your manifest).

jobId

A unique job ID for scheduling; must be the same value for all work enqueued for the same class.

work

The Intent of work to enqueue.


open fun enqueueWork(@NonNull context: @NonNull Context, @NonNull component: @NonNull ComponentName, jobId: Int, @NonNull work: @NonNull Intent)(source)

Like enqueueWork, but supplies a ComponentName for the service to interact with instead of its class.

Parameters

context

Context this is being called from.

component

The published ComponentName of the class this work should be dispatched to.

jobId

A unique job ID for scheduling; must be the same value for all work enqueued for the same class.

work

The Intent of work to enqueue.